﻿using UnityEngine;

namespace UFrame
{
    public class AnimaEventDelivery : MonoBehaviour
    {
        public GameObject animaGO;
        public bool isParentDelivery = true;

        public void OnAnimaEvent(string args)
        {
            if (isParentDelivery)
            {
                var receive = gameObject.GetComponentInParent<IAnimaEvent>();
                if (receive != null)
                {
                    receive.OnAnimaEvent(args);
                }
            }

            if (animaGO != null)
            {
                var e = animaGO.GetComponent<IAnimaEvent>();
                if (e == null)
                    Debug.LogError("Monohavior not implement IAnimaEvent");
                else
                    e.OnAnimaEvent(args);
            }
        }
    }

    public interface IAnimaEvent
    {
        void OnAnimaEvent(string args);
    }
    
    public interface IAnimaStateEvent
    {
        void OnAnimaStateEvent(string args);
    }
    
}